package com.ruoyi.construction.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.construction.domain.JwMajorConstruction;
import com.ruoyi.construction.service.IJwMajorConstructionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专业建设情况Controller
 * 
 * @author ruoyi
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/construction/construction")
public class JwMajorConstructionController extends BaseController
{
    @Autowired
    private IJwMajorConstructionService jwMajorConstructionService;

    /**
     * 查询专业建设情况列表
     */
    @PreAuthorize("@ss.hasPermi('construction:construction:list')")
    @GetMapping("/list")
    public TableDataInfo list(JwMajorConstruction jwMajorConstruction)
    {
        startPage();
        List<JwMajorConstruction> list = jwMajorConstructionService.selectJwMajorConstructionList(jwMajorConstruction);
        return getDataTable(list);
    }

    /**
     * 导出专业建设情况列表
     */
    @PreAuthorize("@ss.hasPermi('construction:construction:export')")
    @Log(title = "专业建设情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JwMajorConstruction jwMajorConstruction)
    {
        List<JwMajorConstruction> list = jwMajorConstructionService.selectJwMajorConstructionList(jwMajorConstruction);
        ExcelUtil<JwMajorConstruction> util = new ExcelUtil<JwMajorConstruction>(JwMajorConstruction.class);
        util.exportExcel(response, list, "专业建设情况数据");
    }

    /**
     * 获取专业建设情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('construction:construction:query')")
    @GetMapping(value = "/{mcId}")
    public AjaxResult getInfo(@PathVariable("mcId") Long mcId)
    {
        return success(jwMajorConstructionService.selectJwMajorConstructionByMcId(mcId));
    }

    /**
     * 新增专业建设情况
     */
    @PreAuthorize("@ss.hasPermi('construction:construction:add')")
    @Log(title = "专业建设情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JwMajorConstruction jwMajorConstruction)
    {
        return toAjax(jwMajorConstructionService.insertJwMajorConstruction(jwMajorConstruction));
    }

    /**
     * 修改专业建设情况
     */
    @PreAuthorize("@ss.hasPermi('construction:construction:edit')")
    @Log(title = "专业建设情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JwMajorConstruction jwMajorConstruction)
    {
        return toAjax(jwMajorConstructionService.updateJwMajorConstruction(jwMajorConstruction));
    }

    /**
     * 删除专业建设情况
     */
    @PreAuthorize("@ss.hasPermi('construction:construction:remove')")
    @Log(title = "专业建设情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mcIds}")
    public AjaxResult remove(@PathVariable Long[] mcIds)
    {
        return toAjax(jwMajorConstructionService.deleteJwMajorConstructionByMcIds(mcIds));
    }
}
